package com.y.architecture.util;

import android.content.Context;
import android.net.ConnectivityManager;
import android.util.Log;

/**
 * Created by youjingjing on 2017/12/21.
 */

public class NetWorkUtil {
    /**
     * 判断网络是否可用
     * @param context
     * @return
     */
    public static boolean isNetWorkAvailable(Context context){
        ConnectivityManager connectivityManager = (ConnectivityManager)
                context.getSystemService(Context.CONNECTIVITY_SERVICE);
        if(connectivityManager != null){
            if(connectivityManager.getActiveNetworkInfo().isAvailable()){
                Log.e("network---","avaliabale");
                return true;
            }
        }
        return false;
    }
}
